$(function() {
    var senseContent =
        "<div class='edit-box' id='senseDemo'>" +
        "<div class='header'>编辑传感</h4> </div>" +
        "<div class='modal-body'>" +
        "<div class='input-group'><label'><span>地址:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'></div>" +
        "<div class='input-group'><label'><span>坐标:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'></div>" +
        "<div class='classify-input input-group'><label><span>编号:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'><label><span>材质:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'></div>" +
        "<div class='classify-input input-group'><label><span>类别:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'><label><span>寿命:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'></div>" +
        "<div class='classify-input input-group'><label><span>名称:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'><label><span>责任:</span></label><input class='form-control' type='text' id=''></div>" +
        "<div class='classify-input input-group'><label><span>年份:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'><label><span>部门:</span></label><input class='form-control' type='text' id=''></div>" +
        "<div class='classify-input input-group'><label><span>规格:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'></div>" +
        "<div class='remark-input input-group'><label><span>备注:</span></label><textarea class='form-control' type='text' id=''></textarea></div>" +  
        " <div class='modal-footer'>" +
        "<button type='button' class='btn ensure-btn' id='add-user'>确定</button><button type='button' class='btn btn-default' data-dismiss='modal'>取消</button>" +
        "</div>" +
        " </div>" +
        "</div>";
    var boxContent =
        "<div class='edit-box' id='boxDemo' >" +
        "<div class='header'>编辑涵匣</h4> </div>" +
        "<div class='modal-body'>" +
        "<div class='input-group'><label'><span>地址:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'></div>" +
        "<div class='input-group'><label'><span>坐标:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'></div>" +
        "<div class='classify-input input-group'><label><span>编号:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'><label><span>材质:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'></div>" +
        "<div class='classify-input input-group'><label><span>类别:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'><label><span>寿命:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'></div>" +
        "<div class='classify-input input-group'><label><span>名称:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'><label><span>责任:</span></label><input class='form-control' type='text' id=''></div>" +
        "<div class='classify-input input-group'><label><span>年份:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'><label><span>部门:</span></label><input class='form-control' type='text' id=''></div>" +
        "<div class='remark-input input-group'><label><span>备注:</span></label><textarea class='form-control' type='text' id=''></textarea></div>" +
        " <div class='modal-footer'>" +
        "<button type='button' class='btn ensure-btn' id='add-user'>确定</button><button type='button' class='btn btn-default' data-dismiss='modal'>取消</button>" +
        "</div>" +
        " </div>" +
        "</div>";
    var buildContent =
        "<div class='edit-box' id='buildDemo' >" +
        "<div class='header'>编辑建筑</h4> </div>" +
        "<div class='modal-body'>" +
        "<div class='input-group'><label'><span>地址:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'></div>" +
        "<div class='input-group'><label'><span>坐标:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'></div>" +
        "<div class='classify-input input-group'><label><span>编号:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'><label><span>材质:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'></div>" +
        "<div class='classify-input input-group'><label><span>类别:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'><label><span>寿命:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'></div>" +
        "<div class='classify-input input-group'><label><span>名称:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'><label><span>责任:</span></label><input class='form-control' type='text' id=''></div>" +
        "<div class='classify-input input-group'><label><span>年份:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'><label><span>部门:</span></label><input class='form-control' type='text' id=''></div>" +
        "<div class='remark-input input-group'><label><span>备注:</span></label><textarea class='form-control' type='text' id=''></textarea></div>" +
        " <div class='modal-footer'>" +
        "<button type='button' class='btn ensure-btn' id='add-user'>确定</button><button type='button' class='btn btn-default' data-dismiss='modal'>取消</button>" +
        "</div>" +
        " </div>" +
        "</div>";
    var coverContent =
        "<div class='edit-box' id='coverDemo' >" +
        "<div class='header'>编辑井盖</h4> </div>" +
        "<div class='modal-body'>" +
        "<div class='input-group'><label'><span>地址:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'></div>" +
        "<div class='input-group'><label'><span>坐标:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'></div>" +
        "<div class='classify-input input-group'><label><span>编号:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'><label><span>材质:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'></div>" +
        "<div class='classify-input input-group'><label><span>类别:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'><label><span>寿命:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'></div>" +
        "<div class='classify-input input-group'><label><span>名称:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'><label><span>责任:</span></label><input class='form-control' type='text' id=''></div>" +
        "<div class='classify-input input-group'><label><span>年份:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'><label><span>部门:</span></label><input class='form-control' type='text' id=''></div>" +
        "<div class='classify-input input-group'><label><span>规格:</span></label><input class='form-control' type='text' id='' value='湖里区金泰路'></div>" +
        "<div class='remark-input input-group'><label><span>备注:</span></label><textarea class='form-control' type='text' id=''></textarea></div>" +
        " <div class='modal-footer'>" +
        "<button type='button' class='btn ensure-btn' id='add-user'>确定</button><button type='button' class='btn btn-default' data-dismiss='modal'>取消</button>" +
        "</div>" +
        " </div>" +
        "</div>";
    var map = new BMap.Map("map"); // 百度地图API定位一个厦门大位置功能
    var point = new BMap.Point(118.10388605, 24.48923061);
    var senseWindow = new BMap.InfoWindow(senseContent); // 创建信息窗口对象
    var boxWindow = new BMap.InfoWindow(boxContent); // 创建信息窗口对象
    var buildWindow = new BMap.InfoWindow(buildContent); // 创建信息窗口对象
    var coverWindow= new BMap.InfoWindow(coverContent); // 创建信息窗口对象
    map.centerAndZoom(point, 15);
    map.enableScrollWheelZoom();
    //创建传感小图标
    var pt = new BMap.Point(118.10388605, 24.5);
    var myIcon = new BMap.Icon("images/sense.png", new BMap.Size(300, 157));
    var marker = new BMap.Marker(pt, { icon: myIcon }); // 创建标注
    map.addOverlay(marker);
    marker.addEventListener("click", function() {
        this.openInfoWindow(senseWindow);
        //图片加载完毕重绘infowindow
        document.getElementById('senseDemo').onload = function() {
            senseWindow.redraw(); //防止在网速较慢，图片未加载时，生成的信息框高度比图片的总高度小，导致图片部分被隐藏
        }
    });
    //创建涵匣小图标
    var pt = new BMap.Point(118.10388605, 24.48923061);
    var myIcon = new BMap.Icon("images/box.png", new BMap.Size(300, 157));
    var marker2 = new BMap.Marker(pt, { icon: myIcon }); // 创建标注
    map.addOverlay(marker2);
    marker2.addEventListener("click", function() {
        this.openInfoWindow(boxWindow);
        //图片加载完毕重绘infowindow
        document.getElementById('boxDemo').onload = function() {
            boxWindow.redraw(); //防止在网速较慢，图片未加载时，生成的信息框高度比图片的总高度小，导致图片部分被隐藏
        }
    });
    //创建建筑小图标
    var pt = new BMap.Point(118.10388605, 24.49923061);
    var myIcon = new BMap.Icon("images/build.png", new BMap.Size(500, 157));
    var marker3 = new BMap.Marker(pt, { icon: myIcon }); // 创建标注
    map.addOverlay(marker3);
    marker3.addEventListener("click", function() {
        this.openInfoWindow(buildWindow);
        //图片加载完毕重绘infowindow
        document.getElementById('buildDemo').onload = function() {
            buildWindow.redraw(); //防止在网速较慢，图片未加载时，生成的信息框高度比图片的总高度小，导致图片部分被隐藏
        }
    });
    //创建井盖小图标
    var pt = new BMap.Point(118.10388605, 24.38);
    var myIcon = new BMap.Icon("images/cover.png", new BMap.Size(500, 157));
    var marker4 = new BMap.Marker(pt, { icon: myIcon }); // 创建标注
    map.addOverlay(marker4);
    marker4.addEventListener("click", function() {
        this.openInfoWindow(coverWindow);
        //图片加载完毕重绘infowindow
        document.getElementById('coverDemo').onload = function() {
            coverWindow.redraw(); //防止在网速较慢，图片未加载时，生成的信息框高度比图片的总高度小，导致图片部分被隐藏
        }
    });


})
